/**
 * <p>文件名:		TTT.java</p>
 * <p>版权:		CopyrightTag</p>
 * <p>公司:		CompanyTag</p>
 * @author		周华彬(zhouhuabin@sinoiov.com, zhou_hua_bin@163.com)
*/

package com.caits.lbs.framework.listener;

/**
 * <p>CustomizedPropertyConfigurer</p>
 * <p>扩展属性类</p>
 *
 * @author		周华彬(zhouhuabin@sinoiov.com, zhou_hua_bin@163.com)
 * @version		0.0.0
 * <table style="border:1px solid gray;">
 * <tr>
 * <th width="100px">版本号</th><th width="100px">动作</th><th width="100px">修改人</th><th width="100px">修改时间</th>
 * </tr>
 * <!-- 以 Table 方式书写修改历史 -->
 * <tr>
 * <td>0.0.0</td><td>创建类</td><td>admin</td><td>2016年9月28日 下午9:59:15</td>
 * </tr>
 * <tr>
 * <td>XXX</td><td>XXX</td><td>XXX</td><td>XXX</td>
 * </tr>
 * </table>
 */
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

import com.alibaba.fastjson.JSON;
  
public class CustomizedPropertyConfigurer extends PropertyPlaceholderConfigurer {  
	/** 变量:TODO,类型:Logger */
	private org.apache.logging.log4j.Logger LOG = LogManager.getLogger(getClass());
	/** 变量:允许跨域的列表,类型:List<String> */
	private static List<String> allowDomainList;
    private static Map<String, Object> ctxPropertiesMap= new HashMap<String, Object>();  ;  
  
    @Override  
    protected void processProperties(ConfigurableListableBeanFactory beanFactory,  
            Properties props)throws BeansException {  
  
        super.processProperties(beanFactory, props);  
        //load properties to ctxPropertiesMap  
        for (Object key : props.keySet()) {  
            String keyStr = key.toString();  
            String value = props.getProperty(keyStr);  
            ctxPropertiesMap.put(keyStr, value);  
        }
        LOG.info("获取所有属性值:"+JSON.toJSONString(ctxPropertiesMap));
    }  
  
    //static method for accessing context properties  
    public static Object getContextProperty(String name) {  
        return ctxPropertiesMap.get(name);  
    }  
	/**
	 * 获取属性 allowDomainList的值
	 * @return the allowDomainList : List<String>
	 */
	public static List<String> getAllowDomainList() {
		return allowDomainList;
	}

	/**
	 * 设置属性allowDomainList的值，参数类型List<String>
	 * @param allowDomainList the allowDomainList to set
	 */
	public void setAllowDomainList(List<String> allowDomainList) {
		this.allowDomainList = allowDomainList;
	}
}  
